package com.minwei.bigrichman.service.Impl;

import com.minwei.bigrichman.pojo.dto.RichGameInstanceDTO;
import com.minwei.bigrichman.pojo.param.GameStartUserInfoParam;
import com.minwei.bigrichman.result.CommonResult;
import com.minwei.bigrichman.service.RichGameInstanceService;
import com.minwei.bigrichman.utils.UniqueRoomIdGenerator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;


/**
 * @author: <a href="xjm01611253@alibaba-inc.com">肖建民</a>
 * @date: 2024/8/9
 * @time: 17:09
 * @description:
 */
@Component
public class RichGameInstanceServiceImpl implements RichGameInstanceService {
    @Resource
    private UniqueRoomIdGenerator uniqueRoomIdGenerator;
    @Override
    public CommonResult<Boolean> insertGameInfo(GameStartUserInfoParam gameStartUserInfoParam) {

        //存入数据库
        RichGameInstanceDTO richGameInstanceDTO = gameStartUserInfoParam2Dto(gameStartUserInfoParam);

        return null;
    }


    private RichGameInstanceDTO gameStartUserInfoParam2Dto(GameStartUserInfoParam gameStartUserInfoParam){
        //生成房间号
        String roomId = String.format("%08d", uniqueRoomIdGenerator.generateUniqueId());
        //拼装用户信息

        RichGameInstanceDTO.builder()
                .id(Long.valueOf(roomId))
                .instanceUserInfo()
                .build();
        return null;
    }

}
